﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <input type="hidden" id="id" name="id" />
        <div class="form-group">
            <label class="col-sm-3 control-label">职位名称<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="positionName" name="positionName" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">显示顺序</label>
            <div class="col-sm-8">
                <input id="positionSort" name="positionSort" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态</label>
            <div id="positionStatus" name="positionStatus" class="col-sm-8"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        $("#positionStatus").ysRadioBox({
            data: ys.getJson(@Html.Raw(typeof(StatusEnum).EnumToDictionaryString()))
        });

        getForm();

        $("#form").validate({
            rules: {
                positionName: { required: true }
            }
        });
    });

    function getForm() {
        //修改赋值使用
        var editData = storage.get("editData");
        if (editData != null && editData.length > 0) {
            //表单赋值
            $("#form").setWebControls(JSON.parse(editData));
        } else {
            //界面初始化 给状态、性别赋值
            var defaultData = {};
            defaultData.positionStatus = 1;
            $("#form").setWebControls(defaultData);
        }
    }
    //提交数据
    function submitForm(index) {
        if ($("#form").validate().form()) {
            var postData = $("#form").getWebControls();
            $.operate.save("/OrganizationManage/Position/SaveFormJson", postData);
        }
    }
</script>
